package wms.service.dict;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import wms.dao.dict.DataDictMapper;
import wms.entity.DataDict;

@Service
public class DataDictServiceImpl implements DataDictService {
	
	@Resource
	private DataDictMapper dataMapper;
	
	
	@Override
	public List<DataDict> listDataDict(String typeCode) throws Exception {
		return dataMapper.listDataDict(typeCode);
	}


	@Override
	public DataDict getDataDict(String typeCode, Integer valueId) throws Exception {
		return dataMapper.getDataDict(typeCode, valueId);
	}


	@Override
	public boolean modifyDataDict(DataDict dataDict) throws Exception {
		if (getDataDict(dataDict.getTypeCode(), dataDict.getValueId()) == null) {
			return false;
		}
		return dataMapper.txModify(dataDict);
	}


	@Override
	public boolean saveDataDict(DataDict dataDict) throws Exception {
		if (getDataDict(dataDict.getTypeCode(), dataDict.getValueId()) == null) {
			return dataMapper.txSave(dataDict);
		}
		return false;  
	}

}
